<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link rel="stylesheet"
	href="${pageContext.request.contextPath}/themes/bootstrap/easyui.css" />
<link type="text/css"
	href="${pageContext.request.contextPath}/themes/icon.css"
	rel="stylesheet">
<script type="text/javascript"
	src="${pageContext.request.contextPath}/js/jquery-1.9.1.js"></script>
<script type="text/javascript"
	src="${pageContext.request.contextPath}/js/jquery.easyui.min.js"></script>
<script type="text/javascript"
	src="${pageContext.request.contextPath}/js/easyui-lang-zh_CN.js"></script>
<title>Insert title here</title>
</head>
<script type="text/javascript">

$(function(){
	//会员展示表格
	$('#dg').datagrid({    
	    url:'showVipLXG',
	    rownumbers : true,
		pagination : true,
		pagePosition : 'bottom',
		pageSize : 10,
		pageList : [ 10, 15, 20 ],
		autoRowHeight : false,
	    columns:[[ 
            {field:'checkbox',title:'',checkbox:true,width:200},      
	        {field:'vId',title:'会员编号',width:200,hidden : true,align:'center'},    
	        {field:'vPoint',title:'会员积分',width:200,align:'center'},    
	        {field:'pitRate',title:'积分转化率',width:200,align:'center'},
	        {field:'vDiscount',title:'会员折扣率',width:200,align:'center'},
	        {field:'vTme',title:'开通时间',width:200,align:'center'},
	    ]] 	
	});
	
	//工具栏
	$('#dg').datagrid({
		toolbar: [{
			//增加功能
			iconCls: 'icon-add',
			text:'增加',
			handler: function(){
				//清除值
				$('#tb1').textbox('clear');				
				$('#cc').combobox('clear');
				$('#cc1').combobox('clear');
				
				$('#win').window('open');
				
				
			}
		},'-',{
			//删除功能
			iconCls: 'icon-remove',
			text:'删除',
			handler: function(){
				var vc=	$('#dg').datagrid('getSelections');
				if(vc.length>0){
					$.messager.confirm('确认对话框', '您确定要删除嘛？', function(r){
						if (r){
							$.each(vc, function(i, n){
								  $.ajax({
									url:'deleteVIPLXG',
									type:'post',
									data:{'vId':vc[i].vId},
									dataType:'json',
									success:function(data){
										if(data==1){
											$.messager.show({
												title:'我的消息',
												msg:'删除成功',
												timeout:2000,
												showType:'slide'
											});
											$('#dg').datagrid('reload');

										}else{
											$.messager.show({
												title:'我的消息',
												msg:'删除失败',
												timeout:2000,
												showType:'slide'
											});

										}
										
									}
									  
								  })
								});
						}
					});


					
				}else{
					$.messager.alert('我的消息','请选择您要删除的信息！','info');
				}
			}
		},'-',{
			//修改功能
			iconCls: 'icon-edit',
			text:'修改',
			handler: function(){
				var vc=	$('#dg').datagrid('getSelections');
				if(vc.length==1){
					$('#win2').window('open');
					$('#dd1').datebox('setValue', '');
					//赋值
					$('#tb5').textbox('setValue',vc[0].vId);
					$('#tb6').textbox('setValue',vc[0].vPoint);
					$('#cc2').combobox('setValue',vc[0].pitRate);
					$('#cc3').combobox('setValue',vc[0].vDiscount);
					$('#dd1').datebox('setValue', vc[0].vTme);
				}else{
					$.messager.alert('我的消息','请您选择一条信息进行修改','info');


				}
			}
		},'-',{
			//查询功能
			iconCls: 'icon-search',
			text:'查询',
			handler: function(){
				$.messager.prompt('提示信息', '请输入查询关键字：', function(r){
					if (r){
						$('#dg1').datagrid({    
						    url:'selectVIPByKeyLXG',
						    rownumbers : true,
							pagination : true,
							title:'查询信息',
							
							pagePosition : 'bottom',
							pageSize : 10,
							pageList : [ 10, 15, 20 ],
							autoRowHeight : false,
							closable:true,
							queryParams: {keyword:r},

						    columns:[[ 
					            {field:'checkbox',title:'',checkbox:true,width:200},      
						        {field:'vId',title:'会员编号',width:200,hidden : true,align:'center'},    
						        {field:'vPoint',title:'会员积分',width:200,align:'center'},    
						        {field:'pitRate',title:'积分转化率',width:200,align:'center'},
						        {field:'vDiscount',title:'会员折扣率',width:200,align:'center'},
						        {field:'vTme',title:'开通时间',width:200,align:'center'},
						    ]] 	
						});
						
					}
				});


				
			}
		}]
	});
	
	
	
	
	//增加功能确定按钮的事件
	$('#btn1').bind('click', function(){  		
		//取值
		var vPoint=$('#tb1').textbox('getValue');		
		var pitRate=$('#cc').combobox('getValue');
		var vDiscount=$('#cc1').combobox('getValue');
		
		//异步请求
		$.ajax({
			url:'insertVIPLXG',
			type:'post',
			data:{'vPoint':vPoint,'pitRate':pitRate,'vDiscount':vDiscount},
			dataType:'json',
			success:function(data){
				if(data==1){
					$.messager.show({
						title:'我的消息',
						msg:'增加成功',
						timeout:2000,
						showType:'slide'
					});
					$('#win').window('close');
					$('#dg').datagrid('reload');
				}else{
					$.messager.show({
						title:'我的消息',
						msg:'增加失败',
						timeout:2000,
						showType:'slide'
					});
					$('#win').window('close');
				}
				
			}
		})
    });    
	//增加功能取消按钮的事件
	$('#btn2').bind('click', function(){
		$('#win').window('close');
	})
	
	
	//修改功能确定按钮的事件
	$('#btn3').bind('click', function(){
		//取值
		var vId=$('#tb5').textbox('getValue');
		var vPoint=$('#tb6').textbox('getValue');
		var pitRate=$('#cc2').combobox('getValue');
			
		var vDiscount=$('#cc3').combobox('getValue');
		
		var vTime = $('#dd1').datebox('getValue');
		$.ajax({
			url:'updateVIPLXG',
			type:'post',
			data:{'vId':vId,'vPoint':vPoint,'pitRate':pitRate,'vDiscount':vDiscount,'vTime':vTime},
			dataType:'json',
			success:function(data){
				if(data==1){
					$.messager.show({
						title:'我的消息',
						msg:'修改成功',
						timeout:2000,
						showType:'slide'
					});
					$('#win2').window('close');
					$('#dg').datagrid('reload');
				}else{
					$.messager.show({
						title:'我的消息',
						msg:'修改失败',
						timeout:2000,
						showType:'slide'
					});
					$('#win2').window('close');
				}
			}
			})
		
		
	})
	
	//修改功能取消按钮的事件
	$('#btn4').bind('click', function(){
		$('#win2').window('close');
		
	})
	
	
	

	


	
})

</script>
<body>
<!-- 会员展示表格 -->
<table id="dg"></table> 


<!-- 增加功能的窗口 -->

<div id="win" class="easyui-window" title="新增会员" style="width:600px;height:400px"   
        data-options="iconCls:'icon-add',modal:true,closed:true">   
   <div style="margin-left: 120px;margin-top: 70px">
  <div style="display:none">vId<input class="easyui-textbox" id="tb" style="width:300px"></div><br><br>
   积&nbsp;&nbsp;&nbsp;分   <input class="easyui-textbox" id="tb1" style="width:300px"><br><br>
 转换率                                        <select id="cc" class="easyui-combobox" name="dept" style="width:300px;">   
    <option>0.1</option>   
    <option>0.2</option>   
    <option>0.3</option>   
    <option>0.4</option>   
    <option>0.5</option>   
</select> <br><br>
折扣率                                          <select id="cc1" class="easyui-combobox" name="dept" style="width:300px;">   
    <option>0.98</option>   
    <option>0.95</option>   
    <option>0.92</option>   
    <option>0.90</option>   
    <option>0.88</option>   
</select><br><br>

<div style="margin-left: 120px;margin-top: 15px">
<a id="btn1" href="#" class="easyui-linkbutton">确定</a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<a id="btn2" href="#" class="easyui-linkbutton">取消</a><br><br>
  </div> </div>   
</div>


<!-- 修改功能的窗口 -->

<div id="win2" class="easyui-window" title="修改会员" style="width:600px;height:400px"   
        data-options="iconCls:'icon-edit',modal:true,closed:true">   
   <div style="margin-left: 120px;margin-top: 70px">
  <div style="display:none">vId<input class="easyui-textbox" id="tb5" style="width:300px"></div><br><br>
   积&nbsp;&nbsp;&nbsp;分   <input class="easyui-textbox" id="tb6" style="width:300px"><br><br>
 转换率                                          <select id="cc2" class="easyui-combobox" name="dept" style="width:300px;">   
    <option>0.1</option>   
    <option>0.2</option>   
    <option>0.3</option>   
    <option>0.4</option>   
    <option>0.5</option>   
</select><br><br>
折扣率                                          <select id="cc3" class="easyui-combobox" name="dept" style="width:300px;">   
    <option>0.98</option>   
    <option>0.95</option>   
    <option>0.92</option>   
    <option>0.90</option>   
    <option>0.88</option>   
</select><br><br>
日&nbsp;&nbsp;&nbsp;期      <input id="dd1" type="text" class="easyui-datebox" style="width:300px"></input><br><br>
<div style="margin-left: 120px;margin-top: 15px">
<a id="btn3" href="#" class="easyui-linkbutton">确定</a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<a id="btn4" href="#" class="easyui-linkbutton">取消</a><br><br>
  </div> </div>   
</div>

<!-- 查询功能的表格 -->
<div style="width:865px;height:400px;padding:7px">
	<div class="easyui-panel" style="width:200px;height:100px"
			data-options="fit:true,closable:true,border:false">
		<table id="dg1"></table> 
	</div>
</div>





</body>
</html>